package com.laowang.project.system.controller;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.google.gson.Gson;
import com.laowang.common.exception.CustomException;
import com.laowang.common.utils.*;
import com.laowang.common.utils.http.HttpKit;
import com.laowang.common.utils.security.Md5Utils;
import com.laowang.framework.config.AsyncUtil;
import com.laowang.framework.interceptor.annotation.RepeatSubmit;
import com.laowang.framework.listener.Event;
import com.laowang.framework.listener.EventPublisher;
import com.laowang.framework.listener.UtilMoney;
import com.laowang.framework.web.page.TableDataInfoMy;
import com.laowang.project.pay.config.MyWxPayConfigUtil;
import com.laowang.project.system.domain.*;
import com.laowang.project.system.domain.vo.*;
import com.laowang.project.system.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;
import sun.misc.Request;

import javax.servlet.http.HttpServletRequest;

/**
 * order对象Controller
 *
 * @author laowang
 * @date 2022-12-21
 */
@Slf4j
@Api(tags = "微信下单接口")
@RestController
@RequestMapping("/order")
public class WxOrderController extends BaseController {
    @Autowired
    private WxOrderService wxOrderService;

    @Autowired
    private MyCyhActivityService myCyhActivityService;

    @Autowired
    private MyCyhActivitySignService myCyhActivitySignService;

    @Autowired
    private UserGoldLogService userGoldLogService;

    @Autowired
    private MyCyhTicketService myCyhTicketService;

    @Autowired
    private EventPublisher eventPublisher;

    @Autowired
    private AsyncUtil asyncUtil;

    @Autowired
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;

    @Autowired
    private UtilMoney utilMoney;


    @Autowired
    private MyCouponService myCouponService;

    @Autowired
    private MyProductService myProductService;

    @Autowired
    private MyCyhShopService myCyhShopService;

    @Autowired
    private ZcWxOrderService zcWxOrderService;

    @Autowired
    private ZcActivityService zcActivityService;

    @RepeatSubmit
    @ApiOperation(value = "小程序端 下单",notes = "")
    @PostMapping("/payOrder")
    public AjaxResult  payOrder(@RequestBody WxOrder wxOrder, HttpServletRequest request) {
        if (Objects.isNull(wxOrder.getType())){
          return   AjaxResult.error("类型不能为空");
        }
        if (StringUtils.isEmpty(wxOrder.getRemark())){
            return   AjaxResult.error("备注信息不能为空");
        }
        Map<String, Object> map = wxOrderService.payOrder(wxOrder,request);
        return AjaxResult.success("操作成功",map);
    }

    @ApiOperation(value = "小程序端 我的订单",notes = "")
    @PostMapping("/myOrder")
    public TableDataInfoMy myOrder(@RequestBody WxOrder wxOrder) {
        Integer mid = SecurityUtils.getLoginUser().getWxUser().getMid();
        wxOrder.setUserId(mid);
        PageHelper.startPage(wxOrder.getPageNum(),wxOrder.getPageSize());
        List<WxOrder> wxOrders = wxOrderService.selectWxOrderListWeb(wxOrder);

        return getDataTableMy(wxOrders);
    }

    @ApiOperation(value = "小程序端 订单详情",notes = "")
    @GetMapping("/detail/{orderId}")
    public AjaxResult myOrder(@PathVariable("orderId") String orderId) {
        WxOrder wxOrder = wxOrderService.selectWxOrderById(orderId);
        if (wxOrder == null){
            throw new CustomException("订单为空检查参数",400);
        }
        if ( wxOrder.getType().equals(3)){
            MyCyhActivity myCyhActivity = myCyhActivityService.selectMyCyhActivityById(Integer.valueOf(wxOrder.getRemark()));
            if (myCyhActivity == null){
                throw new CustomException("活动已结束",400);
            }

            wxOrder.setActivityName(myCyhActivity.getTitle());
            wxOrder.setIsRefund(myCyhActivity.getIsRefund());
        }


        if (wxOrder.getType().equals(6)){
            MyProduct myProduct = myProductService.selectMyProductByProductId(wxOrder.getId());
            wxOrder.setMyProduct(myProduct);
            MyCyhShop myCyhShop = myCyhShopService.selectMyCyhShopById(myProduct.getShopId());
            if (myCyhShop !=null){
                myProduct.setShopName(myCyhShop.getName());
            }
        }
        if (wxOrder.getType().equals(7)){
            MyCoupon myCoupon=   myCouponService.selectMyCouponByOrderId(wxOrder.getId());
            wxOrder.setMyCoupon(myCoupon);
            MyCyhShop myCyhShop = myCyhShopService.selectMyCyhShopById(myCoupon.getShopId());
            if (myCyhShop !=null){
                myCoupon.setShopName(myCyhShop.getName());
            }
        }
        if (wxOrder.getType().equals(13)){
            MyCyhShop myCyhShop = myCyhShopService.selectMyCyhShopById(Integer.valueOf(wxOrder.getRemark()) );
            wxOrder.setShopName(myCyhShop.getName());

        }
        return AjaxResult.success("操作成功",wxOrder);
    }


    @ApiOperation(value = "前端支付回调参数", notes = "")
    @GetMapping("/wxApp/notify")
    public AjaxResult notify(String orderId) {
        System.out.println("前端传递的参数:" + orderId);
        WxOrder wxOrder = wxOrderService.selectWxOrderById(orderId);
        if (wxOrder !=null){
            wxOrder.setStatus(1);
            wxOrderService.updateNotify(wxOrder);

        }else {
            throw new CustomException("该订单不存在",400);
        }
        return AjaxResult.success("操作成功");
    }



    /**
     *
     * 星pos 回调地址
     *   https://mcjlb.cn/cyh/order/gtpNotify  这个是回调地址  机构号15
     * @param
     * @param request
     * @return
     *      https://wx.mcjlb.cn/cyhh/order/gtpNotify  这个是新的回调地址
     */
    @ApiOperation(value = "前端支付回调参数", notes = "")
    @PostMapping("/gtpNotify")
    public AjaxResult notify02(HttpServletRequest request) {
        String resXml = "";
        InputStream is = null;
        StringBuilder sb = null;
        try {
            is = request.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "GBK"));
            sb = new StringBuilder();
            String line = null;

            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (IOException var18) {
            var18.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException var17) {
                var17.printStackTrace();
            }

        }

        resXml = sb.toString();

        log.info("国通返回的异步通知请求包: {}", resXml);
        Map<String,String> map = JSON.parseObject(resXml, Map.class);
        String txnStatus = map.get("TxnStatus");
        String businessId = map.get("BusinessId");
        if (txnStatus.equals("1") && businessId.equals("800551000056059")) { //廖春香
        //if (txnStatus.equals("1") && businessId.equals("800551000056528")) { //新公司
            String officeId = map.get("OfficeId");
            WxOrder wxOrder = wxOrderService.selectWxOrderByOrderNo(officeId);
            if (wxOrder == null) {
                return AjaxResult.success();
            }
            wxOrder.setStatus(1);
            wxOrderService.updateNotify(wxOrder);

        }
        return AjaxResult.success();
    }

    /**
     * 2025-08-05
     * @param request
     * @return
     * 机构号 61000000585786     https://wx.hubeixiangxiang.com/xcyh/order/gtxyfNotify
     */
    @ApiOperation(value = "国通星驿付回调", notes = "")
    @PostMapping("/gtxyfNotify")
    public Object notify002(HttpServletRequest request) {
        String resXml = "";
        InputStream is = null;
        StringBuilder sb = null;
        try {
            is = request.getInputStream();
          BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
            sb = new StringBuilder();
            String line = null;

            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (IOException var18) {
            var18.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException var17) {
                var17.printStackTrace();
            }

        }

        resXml = sb.toString();

        log.info("国通返回的异步通知请求包: {}", resXml);
        Map<String,String> map = JSON.parseObject(resXml, Map.class);
        /*
        *   国通返回的异步通知请求包:
        * {"WX_AGET_SUBSIDY":"99","CUST_ID":"60000011479929",
        * "MEDIATYPE":"","POS_VOUCHERNO":"244eu9",
        * "THREE_ORDER_NO":"1964886330546585600",
        * "sign":"Bt2m6IsxNSKjIGKPWJPUcD5FqAkvi9/mvLUuF4Bj+wFn7M24Y4x6Kjk51K0dPFZE8g54pi3DZaK/AoYvp9WmVSHNBBYiqQ9V0BaGMxj5MWihJipOxzRZxNaEQgAOxa5H72tfj2W9IvEdPDUsdqXPIcRJwOdQS/Mz0PtLLUCM7sscfsrcCXObdDRzuxj0JTsjIq4hcgBg+evEs7IV67FQLmxi+y7bwHRi6khhDlvfG4oZ+K3T7XT7ldRHiBHznPBH8FpckajOmQ7O/+Rh8K8jGL8TdsNZN2Fbv+yFLyoaorJnioiO6/2Yz3XQza2p8IHFaHy6wnLBkEfL1DwUXjynKg==",
        * "CARD_TYPE":"01","OLD_FEE":"1","ORDER_NO":"20250908TT244eu9",
        * "ACTUAL_PAY_AMT":"1","T_ORDER_NO":"20250908TT244eu9",
        * "DEVICE_NO":"99999999","AGET_ID":"61000000585786",
        * "WX_CUST_SUBSIDY":"0","ORDER_STATUS":"1","POS_PAY_WAY":"",
        * "CODE_AGE_AMT":"0","DISCOUNT_FEE":"0",
        * "BANK_CODE":"ICBC_DEBIT","ORD_TYPE":"","SREF_NO":"",
        * "PROMOTION_DETAIL":"[{\"activity_id\":\"20949429\",\"amount\":\"99\",\"merchant_contribute\":\"0\",\"name\":\"閾惰鍗￠殢鏈虹珛鍑廫",\"other_contribute\":\"0\",\"promotion_id\":\"121461894881\",\"scope\":\"GLOBAL\",\"type\":\"COUPON\",\"wxpay_contribute\":\"99\"}]",
        * "PAY_CHANNEL":"2","REFUND_DIS_AMT":"","DISCOUNT_FLAG":"0",
        * "LIMIT_FEE":"0","DEBT_STATE":"20250908","PAY_WAY":"8",
        * "OLD_TXAMT":"100","TRAN_TYPE_SER":"01","CODE_AMT":"0","TXAMT":"100",
        * "SUB_OPEN_ID":"ovq5LvnBZUi2hhonwuAd2Fx9fYrs","NETR_AMT":"99",
        * "OPEN_ID":"ovq5LvnBZUi2hhonwuAd2Fx9fYrs","MERCH_CONTRIBUTE":"0",
        * "CUST_AMT":"0","TRADING_IP":"113.240.196.88","MERCID":"856342003217413",
        * "CUST_FEE":"1","USTLDAT":"20250908",
        * "T_PAY_NO":"4200002782202509088483164205",
        * "ORDER_TIME":"20250908105950","OLD_ORDER_NO":"",
        * "BANK_NAME":"宸ュ晢閾惰(鍊熻鍗�)"}

         *
        * */
        String cust_id = map.get("CUST_ID");
        String order_status = map.get("ORDER_STATUS");
        String THREE_ORDER_NO = map.get("THREE_ORDER_NO");

        if (order_status.equals("1") && cust_id.equals("60000011479929")) { //名豪车俱乐部
            //判断是zc 开头
            String order_no = map.get("ORDER_NO");
            if (StringUtils.startsWith(THREE_ORDER_NO,"zc")) {
                ZcWxOrder zcWxOrder = zcWxOrderService.selectZcWxOrderById(THREE_ORDER_NO);
                if (zcWxOrder== null){
                    return getMap();
                }

                if (zcWxOrder.getStatus().equals(0)){

                    zcWxOrder.setStatus(1);
                    zcWxOrderService.updateZcWxOrder(zcWxOrder);
                    zcActivityService.updateAmount(zcWxOrder.getActivityId(),zcWxOrder.getTotalPrice());
                }else {
                    return getMap();
                }

            }else {
                WxOrder wxOrder = wxOrderService.selectWxOrderByOrderNo(order_no);
                if (wxOrder == null) {
                    return getMap();
                }
                System.out.println("当前订单状态:"+wxOrder.getStatus());
                if (wxOrder.getStatus().equals(0)){

                    wxOrder.setStatus(1);
                    wxOrderService.updateNotify(wxOrder);
                }else {
                    return getMap();
                }
            }

            //{"rspCod":"","rspMsg":"success"}

        }
        return getMap();
    }

    public Map<String,String> getMap(){
        Map<String,String> map =new HashMap<>();
        map.put("rspCod","200");
        map.put("rspMsg","success");
        return map;
    }

  public static void main(String[] args) {
      String s= "{\"WX_AGET_SUBSIDY\":\"99\",\"CUST_ID\":\"60000011479929\",\"MEDIATYPE\":\"\",\"POS_VOUCHERNO\":\"244eu9\",\"THREE_ORDER_NO\":\"1964886330546585600\",\"sign\":\"Bt2m6IsxNSKjIGKPWJPUcD5FqAkvi9/mvLUuF4Bj+wFn7M24Y4x6Kjk51K0dPFZE8g54pi3DZaK/AoYvp9WmVSHNBBYiqQ9V0BaGMxj5MWihJipOxzRZxNaEQgAOxa5H72tfj2W9IvEdPDUsdqXPIcRJwOdQS/Mz0PtLLUCM7sscfsrcCXObdDRzuxj0JTsjIq4hcgBg+evEs7IV67FQLmxi+y7bwHRi6khhDlvfG4oZ+K3T7XT7ldRHiBHznPBH8FpckajOmQ7O/+Rh8K8jGL8TdsNZN2Fbv+yFLyoaorJnioiO6/2Yz3XQza2p8IHFaHy6wnLBkEfL1DwUXjynKg==\",\"CARD_TYPE\":\"01\",\"OLD_FEE\":\"1\",\"ORDER_NO\":\"20250908TT244eu9\",\"ACTUAL_PAY_AMT\":\"1\",\"T_ORDER_NO\":\"20250908TT244eu9\",\"DEVICE_NO\":\"99999999\",\"AGET_ID\":\"61000000585786\",\"WX_CUST_SUBSIDY\":\"0\",\"ORDER_STATUS\":\"1\",\"POS_PAY_WAY\":\"\",\"CODE_AGE_AMT\":\"0\",\"DISCOUNT_FEE\":\"0\",\"BANK_CODE\":\"ICBC_DEBIT\",\"ORD_TYPE\":\"\",\"SREF_NO\":\"\",\"PROMOTION_DETAIL\":\"[{\\\"activity_id\\\":\\\"20949429\\\",\\\"amount\\\":\\\"99\\\",\\\"merchant_contribute\\\":\\\"0\\\",\\\"name\\\":\\\"閾惰\uE511鍗￠殢鏈虹珛鍑廫\",\\\"other_contribute\\\":\\\"0\\\",\\\"promotion_id\\\":\\\"121461894881\\\",\\\"scope\\\":\\\"GLOBAL\\\",\\\"type\\\":\\\"COUPON\\\",\\\"wxpay_contribute\\\":\\\"99\\\"}]\",\"PAY_CHANNEL\":\"2\",\"REFUND_DIS_AMT\":\"\",\"DISCOUNT_FLAG\":\"0\",\"LIMIT_FEE\":\"0\",\"DEBT_STATE\":\"20250908\",\"PAY_WAY\":\"8\",\"OLD_TXAMT\":\"100\",\"TRAN_TYPE_SER\":\"01\",\"CODE_AMT\":\"0\",\"TXAMT\":\"100\",\"SUB_OPEN_ID\":\"ovq5LvnBZUi2hhonwuAd2Fx9fYrs\",\"NETR_AMT\":\"99\",\"OPEN_ID\":\"ovq5LvnBZUi2hhonwuAd2Fx9fYrs\",\"MERCH_CONTRIBUTE\":\"0\",\"CUST_AMT\":\"0\",\"TRADING_IP\":\"113.240.196.88\",\"MERCID\":\"856342003217413\",\"CUST_FEE\":\"1\",\"USTLDAT\":\"20250908\",\"T_PAY_NO\":\"4200002782202509088483164205\",\"ORDER_TIME\":\"20250908105950\",\"OLD_ORDER_NO\":\"\",\"BANK_NAME\":\"宸ュ晢閾惰\uE511(鍊熻\uE187鍗�)\"}";
      WxOrderController w = new WxOrderController();
      String s1 = w.repairJson(s);
      System.out.println(s1);
      JSONObject jsonObject = JSON.parseObject(s1);
      String cust_id = (String) jsonObject.get("CUST_ID");
      String order_status = (String) jsonObject.get("ORDER_STATUS");
    System.out.println(cust_id);
    System.out.println(order_status);
      //Map<String,String> map = JSON.parseObject(s1, Map.class);
      //System.out.println(map);
  }

  /**
   * 修复 JSON 字符串中的常见问题
   */
  public  String repairJson(String jsonString) {
    if (jsonString == null) return null;

    String repaired = jsonString;

    // 1. 修复编码问题
    //repaired = fixEncodingProblems(repaired);

    // 2. 修复转义问题
    repaired = fixEscapeProblems(repaired);

    // 3. 修复引号问题
    //repaired = fixQuoteProblems(repaired);

    return repaired;
  }


  /**
   * 修复编码问题
   */
  private static String fixEncodingProblems(String json) {
    String fixed = json;

    // 常见的乱码映射
    /*fixed = fixed.replace("閾惰鍗￠殢鏈虹珛鍑廫", "银行随机立减")
        .replace("宸ュ晢閾惰", "工商银行")
        .replace("鍊熻鍗�", "借记卡")
        .replace("閾惰", "银行");
    */
    // 尝试重新编码
    try {
      byte[] bytes = fixed.getBytes(StandardCharsets.ISO_8859_1);
      fixed = new String(bytes, StandardCharsets.UTF_8);
    } catch (Exception e) {
      // 忽略编码转换错误
    }

    return fixed;
  }

  /**
   * 修复转义问题
   */
  private static String fixEscapeProblems(String json) {
    return json.replace("\\", "");
        //.replace("\\\"", "\"")
        //.replace("\\\\", "\\");
  }

  /**
   * 修复引号问题
   */
  private static String fixQuoteProblems(String json) {
    // 确保所有的字符串值都有正确的引号
    Pattern pattern = Pattern.compile(":\"([^\"]*)\"");
    return pattern.matcher(json).replaceAll(":\"$1\"");
  }

    @ApiOperation(value = "小程序端 退款", notes = "")
    @GetMapping("/web/refund")
    public AjaxResult refund(String orderId)  {

        WxOrder wxOrder = wxOrderService.selectWxOrderById(orderId);
        if (wxOrder !=null){
            if (  DateUtil.timeSub12(new Date(), wxOrder.getCreateTime()) >60L){
                throw new CustomException("正在处理订单,1分钟后可退款");
            }

            if (wxOrder.getStatus().equals(2)){
                return AjaxResult.error("订单已退款");
            }
            if (!wxOrder.getType().equals(3)){
                return AjaxResult.error("请联系工作人员退款");
            } else {

                /*threadPoolTaskExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        utilMoney.refound111(wxOrder);
                    }
                });*/

                /*threadPoolTaskExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        MyWxPayConfigUtil myWxPayConfigUtil = new MyWxPayConfigUtil();
                        myWxPayConfigUtil.setDate(new Date());
                        myWxPayConfigUtil.setOrderNo(wxOrder.getOrderNo());
                        myWxPayConfigUtil.setOrderId(wxOrder.getId());
                        myWxPayConfigUtil.setTotalAmount(wxOrder.getTotalPrice().multiply(new BigDecimal(100)).toString());
                        PayUtil.test5(myWxPayConfigUtil);
                    }
                });*/

                wxOrderService.refund(wxOrder);
                //wxOrderService.refund111(wxOrder);


            }


        }else {
            throw new CustomException("该订单不存在",400);
        }
        return AjaxResult.success("操作成功");
    }



    /**
     * 查询order对象列表
     */
    @ApiOperation(value = "查询order对象列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxOrder wxOrder) {

        List<MyCyhActivity> myCyhActivities = myCyhActivityService.selectMyCyhActivityListWeb(null);
        Map<Integer, String> collect = myCyhActivities.stream().collect(Collectors.toMap(MyCyhActivity::getId, MyCyhActivity::getTitle));

        startPage();
        List<WxOrder> list = wxOrderService.selectWxOrderList(wxOrder);
        //System.out.println("list:"+list);
        for (WxOrder order : list) {
            if (order.getType().equals(3)){
                if (collect.containsKey(Integer.valueOf(order.getRemark()) )){
                    order.setActivityName(collect.get(Integer.valueOf(order.getRemark())));
                }
            }
        }
        return getDataTable(list);
    }

    /**
     * 导出order对象列表
     */
    @ApiOperation(value = "导出order对象列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:order:export')")
    @Log(title = "order对象", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WxOrder wxOrder) {

        List<WxOrder> list = wxOrderService.selectWxOrderList(wxOrder);
        List<MyCyhActivity> myCyhActivities = myCyhActivityService.selectMyCyhActivityListWeb(null);
        Map<Integer, String> collect = myCyhActivities.stream().collect(Collectors.toMap(MyCyhActivity::getId, MyCyhActivity::getTitle));
        for (WxOrder order : list) {
            if (order.getType().equals(3)){
                if (collect.containsKey(Integer.valueOf(order.getRemark()) )){
                    order.setActivityName(collect.get(Integer.valueOf(order.getRemark())));
                }
            }
        }

        ExcelUtil<WxOrder> util = new ExcelUtil<WxOrder>(WxOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取order对象详细信息
     */
    @ApiOperation(value = "获取order对象详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(wxOrderService.selectWxOrderById(id));
    }

    /**
     * 新增order对象
     */
    @ApiOperation(value = "新增order对象",notes = "")
    @PreAuthorize("@ss.hasPermi('my:order:add')")
    @Log(title = "order对象", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxOrder wxOrder) {
        return toAjax(wxOrderService.insertWxOrder(wxOrder));
    }

    /**
     * 修改order对象
     */
    @ApiOperation(value = "修改order对象",notes = "")
    @PreAuthorize("@ss.hasPermi('my:order:edit')")
    @Log(title = "order对象", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxOrder wxOrder) {
        return toAjax(wxOrderService.updateWxOrder(wxOrder));
    }

    /**
     * 删除order对象
     */
    @ApiOperation(value = "删除order对象",notes = "")
    @PreAuthorize("@ss.hasPermi('my:order:remove')")
    @Log(title = "order对象", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wxOrderService.deleteWxOrderByIds(ids));
    }
}
